﻿using System;

namespace Sencha.Serialization.Exceptions
{
	[Serializable]
	sealed class TypeContractViolation : DataContractException
	{
		public TypeContractViolation(Type anticipant, Contracts.TypeDescription type, string contract)
			: base(Loc.GetErrorString("Exception_TypeContractViolation", anticipant.Name, type.Name, contract), ErrorCode.TypeContractViolation)
		{
			if (type == null)
				throw new ArgumentNullException("type");
			if (anticipant == null)
				throw new ArgumentNullException("anticipant");
			if (contract == null)
				throw new ArgumentNullException("contract");
			System.Diagnostics.Contracts.Contract.EndContractBlock();
		}
		public TypeContractViolation(Type anticipant, Type type, string contract)
			: base(Loc.GetErrorString("Exception_TypeContractViolation", anticipant.Name, type.Name, contract), ErrorCode.TypeContractViolation)
		{
			if (type == null)
				throw new ArgumentNullException("type");
			if (anticipant == null)
				throw new ArgumentNullException("anticipant");
			if (contract == null)
				throw new ArgumentNullException("contract");
			System.Diagnostics.Contracts.Contract.EndContractBlock();
		}

		protected TypeContractViolation(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
			: base(info, context)
		{
		}
	}
}
